package com.utils.basejava.concurrent.atomic;

import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;

public class BasicTest {
	public static void main(String[] args) {
		AtomicInteger ai = new AtomicInteger();
		System.out.println(ai.get());
		System.out.println(ai.getAndIncrement());//以原子方式将当前值加1 ，并返回自增前的值
		System.out.println(ai.get());
		System.out.println(ai.getAndAdd(2));//以原子方式将输入的数值与实例中的值相加
		System.out.println(ai.get());
		System.out.println(ai.compareAndSet(6, 6));
		System.out.println(ai.get());
		System.out.println(ai.compareAndSet(3, 9));//如果实例中的值等于预期值，以原子方式将实例值设置为给定的更新值
		System.out.println(ai.get());
		
		AtomicLong al = new AtomicLong();
		AtomicBoolean ab = new AtomicBoolean();
	}
}
